package com.adds.lvds.core.utils;

import javax.servlet.ServletContext;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class ApplicationContextUtils {
	private static ServletContext servletContext;

	public static void setServletContext(ServletContext sc) {
		servletContext = sc;
	}

	public static ApplicationContext getApplicationContext() {
		return WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
	};
	
	public static Object getBean(String beanName) {
		return WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext).getBean(beanName);
	}
	
	public static String getApplicationContextPath(){
		return servletContext.getRealPath("/");
	}
}
